// pages/achieveDetails/achieveDetails.js
var app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
      isOther: false
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        var itemDetail = app.globalData.driversOrders;
        console.log(itemDetail, "itemDetail")

        this.setData({
            itemDetail: app.globalData.driversOrders,
            id: itemDetail.id,
        })
        var pickUpNums = 0,
            totalWeight = 0,
            totalVolume = 0,
            pickUpPayedMoney = itemDetail.totalFee;
        for (let i = 0; i < itemDetail.orderGoodInfosList.length; i++) { //费用体积计算
            pickUpNums += itemDetail.orderGoodInfosList[i].nums;
            // pickUpPayedMoney += itemDetail.orders.orderGoodInfosList[i].freight;
            totalWeight += Number(itemDetail.orderGoodInfosList[i].volumeWeight);
            totalVolume += Number(itemDetail.orderGoodInfosList[i].volume)
        }
        var insured = pickUpPayedMoney * itemDetail.insuranceRate //保险金额计算
        this.setData({
            pickUpNums: pickUpNums,
            pickUpPayedMoney: pickUpPayedMoney.toFixed(2),
            totalWeight: totalWeight,
            totalVolume: totalVolume,
            insured: insured
        })
    },
    otherFee() { //查看其它费用
      var that = this
      that.setData({
        itemDetail: app.globalData.driversOrders,
        isOther: !that.data.isOther
      })
      // wx.navigateTo({
      //     url: "../other/other"
      // })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */

})